using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Pages_Employee_EmployeeProfile : System.Web.UI.Page
{
    Account account;

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            string userName = User.Identity.Name;
            account = DALAccount.GetOneAccount(userName);
            SetAllFields();
        }
    }

    protected void SetAllFields()
    {
        txtUserName.Text = account.UserName;
        txtFullName.Text = account.Fullname;
        txtAddress.Text = account.Address;
        txtPhoneNumber.Text = account.PhoneNumber;
        txtEmail.Text = account.Email;
        ddlBranch.SelectedValue = account.PinCode;
    }

    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        lblMessage.Text = "";
        if (Page.IsValid)
        {
            try
            {
                DALAccount.UpdateEmployee(txtUserName.Text, txtFullName.Text, txtAddress.Text, txtEmail.Text, txtPhoneNumber.Text, ddlBranch.SelectedValue);
                lblMessage.Text = "Updated successfully <br/> Please wait for admin's confirmation";
            }
            catch
            {
                lblMessage.Text = "Error updating employee profile";
            }
        }
    }
}
